package cn.hackcloud.mutithread.juc;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class TestCallable {
	public static void main(String[] args) throws Exception {
		CallableDemo demo = new CallableDemo();
		FutureTask<Integer> futureTask = new FutureTask<>(demo);
		new Thread(futureTask).start();
		Integer result = futureTask.get();
		System.out.println("结果是:"+result);
	}
}

class CallableDemo implements Callable<Integer> {

	@Override
	public Integer call() throws Exception {
		int sum = 0;
		for (int i = 0; i <= 100; i++) {
			sum += i;
		}
		return sum;
	}

}